<?php

require(ROOT . '/controllers/CommonController.class.php');

class FtpController extends CommonController {

	public function __construct() {
		parent::__construct(__CLASS__);

		$this->db = DB::open('reading');
	}

	public function indexAction() {
		$serverModel = new Model('ftp_server',$this->db);

		$projectModel = new Model('ftp_project',$this->db);

		$this->assign('servers', $serverModel->query());

		$this->assign('projects', $projectModel->query());

		$this->rend('index');
	}

	public function uploadAction() {
		global $global;
		$files = array();
		foreach (explode("\n", trim(requestPost('files'))) as $item) {
			$files[] = array(
				'localFile' => preg_replace("/^\/trunk/", $global['ftp_local_root'], $item),
				'remoteFile' => preg_replace("/^\/trunk/", $global['ftp_remote_root'], $item)
			);
		}
	}

}
